home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / PHP / PHP.exe / EasyPHP-2.0b1-setup.exe / {app} / sqlitemanager / include / SQLite.i18n.php < prev    next >
Encoding:
PHP Script  |  2006-04-18  |  2.5 KB  |  106 lines

  1. <?php
  2. /**
  3. * Web based SQLite management
  4. * Multilingual management
  5. * @package SQLiteManager
  6. * @author FrΘdΘric HENNINOT
  7. * @version $Id: SQLite.i18n.php,v 1.25 2006/04/14 15:16:52 freddy78 Exp $ $Revision: 1.25 $
  8. */
  9.  
  10. class GestionLangue {
  11.     
  12.     /**
  13.     * Array of all text
  14.     * @var array
  15.     * @access private
  16.     */
  17.     var $tabText;
  18.  
  19.     /**
  20.     * Character encoding
  21.     * @var string
  22.     * @access private
  23.     */
  24.     var $encoding;
  25.     
  26.     /**
  27.     * Class constructor
  28.     *
  29.     * @access public
  30.     * @param $tableau array 
  31.     */
  32.     function GestionLangue($tableau){
  33.         global $currentLangue;
  34.         if(is_array($tableau)){
  35.             $this->tabText = $tableau;
  36.         }
  37.  
  38.         $this->encoding = $GLOBALS["charset"];
  39.         return;        
  40.     }
  41.     
  42.     /**
  43.     * Get the good text to display
  44.     *
  45.     * @access public
  46.     * @param $index int numero du message
  47.     * @param $default string message par dΘfaut
  48.     */
  49.     function get($index,$default='No translate'){
  50.         if($index){
  51.             if(isset($this->tabText[$index]) && $this->tabText[$index]){
  52.               $res = @htmlentities($this->tabText[$index],ENT_NOQUOTES,$this->encoding);
  53.               $res = str_replace('<','<',$res);
  54.               $res = str_replace('>','>',$res);
  55.               $res = str_replace('&','&',$res);
  56.                 return $res;
  57.             } else {
  58.                 return $default;
  59.             }                    
  60.         }
  61.     }    
  62.  
  63.     /**
  64.     * Get the good text to display without html entities
  65.     *
  66.     * @access public
  67.     * @param $index int numero du message
  68.     * @param $default string message par dΘfaut
  69.     */
  70.     function getdirect($index,$default='No translate'){
  71.         if($index){
  72.             if(isset($this->tabText[$index]) && $this->tabText[$index]){
  73.               $res = @html_entity_decode($this->tabText[$index], ENT_NOQUOTES, $this->encoding);
  74.                 return $res;
  75.             } else {
  76.                 return $default;
  77.             }                    
  78.         }
  79.     }    
  80.  
  81. }
  82. if(isset($_POST['Langue'])) {
  83.     $currentLangue = $_POST['Langue'];    
  84.     setcookie('SQLiteManager_currentLangue',$_POST['Langue'],1719241200,'/');
  85.     $_COOKIE['SQLiteManager_currentLangue'] = $currentLangue = $_POST['Langue'];
  86.     echo "<script type=\"text/javascript\">parent.location='index.php';</script>";
  87. } elseif(isset($_COOKIE['SQLiteManager_currentLangue'])) {
  88.     $currentLangue = $_COOKIE['SQLiteManager_currentLangue'];
  89. } else {
  90.     $lang = '';
  91.     if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
  92.         $lang=strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2));
  93.     }
  94.     if($lang=='fr') $currentLangue = 1;
  95.     else $currentLangue = 2;
  96. }
  97.  
  98. if(file_exists('./lang/'.$availableLangue[$currentLangue].'.inc.php')){
  99.     include_once './lang/'.$availableLangue[$currentLangue].'.inc.php';
  100. } else {
  101.     include_once './lang/english.inc.php';
  102. }
  103.  
  104. $traduct = &new GestionLangue($TEXT);
  105. ?>
  106.